package start;

import java.util.ArrayList;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.datasource.DriverManagerDataSource;

public class Test01 {
    public Test01() {
        ApplicationContext context = new ClassPathXmlApplicationContext("META-INF\\beans.xml");
        DriverManagerDataSource datatSource = (DriverManagerDataSource)context.getBean("dataSource");            
        JdbcActorDao jdbcActorDao = new JdbcActorDao();
        jdbcActorDao.setDataSource(datatSource);
        jdbcActorDao.insert(new Actor("alex","khomichenko"));
        jdbcActorDao.insert(new Actor("alexandra","khomichenko"));
        jdbcActorDao.insert(new Actor("julia","demaysh"));
        List<Actor> list = new ArrayList<Actor>();  
        list.add(new Actor(1,"alex - updated","khomichenko - updated"));
        list.add(new Actor(3, "julia - updated", "demaysh - updated"));
        for (int res : jdbcActorDao.batchUpdate(list)) {
            System.out.println(res);    
        }
        System.out.println("--------");
        list.clear();
        list.add(new Actor(4,"alex - updated 2","khomichenko - updated 2"));
        list.add(new Actor(6, "julia - updated 2", "demaysh - updated 2"));
        for (int res : jdbcActorDao.batchUpdate2(list)) {
            System.out.println(res);    
        }
        
        
    }
}
